package com.liuzhilong.infrastructure.basic.jdk.bit;


/**
 * <h2>二进制</h2>
 * <p>二进制的常用功能</p>
 */
public class BitExcute {


    public static void main(String[] args) {
        System.out.println(binaryView((-1L)));
        System.out.println(-1L << 5);
        System.out.println(binaryView((-1L << 5)));
        long size = -1L ^ (-1L << 5);

        System.out.println((1L<<63));
        System.out.println((-1L>>>1));
        System.out.println(binaryView(1L<<63));
        System.out.println(binaryView(size));



        System.out.println(size);
    }

    /**
     * 获取一个整数的二进制表示
     * @param l
     * @return
     */
    public static String binaryView(long l) {
        String m = Long.toBinaryString(l);
        String resultP = "0000000000000000000000000000000000000000000000000000000000000000" + m;
        return  resultP.substring(resultP.length()-64,resultP.length());
    }



}
